<?php


namespace App\Services\Jobposition;


use App\Exceptions\ApiExceptions;
use App\Models\MessageModel;
use App\Models\SignUpJobpositionModel;
use App\Services\AbstractBaseService;


class SignUpService extends AbstractBaseService
{
    public function list(int $user_id)
    {
        return SignUpJobpositionModel::query()->where('user_id',$user_id)->orderByDesc('id')->paginate();
    }
    public function detail(int $user_id,int $id)
    {
        $res  = SignUpJobpositionModel::query()->where('user_id',$user_id)->where('job_position_id',$id)->first();
        if (!$res){
            throw new ApiExceptions('找不到数据');
        }
        $res->message = MessageModel::query()->where('user_id',$user_id)->where('job_position_id',$id)->get();
        return $res;
    }
}